app=$1
full_img_ver=$2


if [ -z "$full_img_ver" ];then
     echo "用法: apply-k8s-web.sh  应用名  完整的镜像:版本号"
     echo "实际参数:  $app,$full_img_ver"
	exit 1
fi

SCRIPTDIR=$(cd $(dirname "${BASH_SOURCE[0]}") >/dev/null && pwd)
cd $SCRIPTDIR

mkdir -p .build


echo ===================================
echo        "部署镜像   $full_img_ver"
echo ===================================


cat web-svr-tmp.txt | sed "s|@app@|$app|ig" | sed "s|@image_version@|$full_img_ver|ig" > .build/k8s-web-svr.yml
kubectl apply -f .build/k8s-web-svr.yml


echo "部署$app完成!"
cd -